#pragma once

#define NETWORK_MAX_RECEIVE_BUFFER  500000

#include <winsock2.h>
#include <string>
#include <assert.h>
#include <iostream>
#include "Runnable.h"
#include "NetworkListener.h"

class NetworkClient : public Runnable
{
protected:
    static unsigned short useCount;

    SOCKET mSocket;
    NetworkListener* listener;

    bool running, active, reconnect;

    unsigned long nextReceiveSize;
    char* data;

    char* host;
    unsigned short port;

public:
    NetworkClient(const char* host, unsigned short port, NetworkListener* listener);
    virtual ~NetworkClient(void);
    
    bool receive(void);
    bool send(char* data, unsigned long length);
    void close(void);
    bool is_running(void);
	int run(void);
};
